//
// Copyright © 2021 dev. All rights reserved.
// 

import Foundation
import SwiftUI


let testSessionID = "wwdc2020-10694"

struct ContentView:View {
    @StateObject var client = WWDCAgentClient()

    @State private var isShowingTestResult = false
    @State private   var selectedSessionId:String?

     private let eventOptions = ["(All Events)", "wwdc2020", "wwdc2019", "wwdc2018", "wwdc2017", "wwdc2016", "wwdc2015", "wwdc2014", "insights", "tech-talks"]
    var body:some View {
        VStack {
            HStack {
                Text("Status:")
                if client.isConnected {
                    Text("Connected")
                    Button("Test"){
                        client.sendTestRequest { _  in
                            client.sendTestRequest { _ in
                                isShowingTestResult = true
                            }
                        }
                    }
                }else {
                    Text("Not Connected")
                }

            }
        }
        .padding()
        .frame(maxWidth:.infinity,maxHeight: .infinity)
        .onAppear{ client.connect()}
        .alert(isPresented: $isShowingTestResult) {
            Alert(title: Text("Success"), message: Text("We got a reply from the agent!"), dismissButton: nil)
        }
    }


}
